home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Ebooks / Thinking in C++ V2 / C20 / PriorityQueue1.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-25  |  512 b   |  22 lines

  1. //: C20:PriorityQueue1.cpp
  2. // From Thinking in C++, 2nd Edition
  3. // Available at http://www.BruceEckel.com
  4. // (c) Bruce Eckel 1999
  5. // Copyright notice in Copyright.txt
  6. #include <iostream>
  7. #include <queue>
  8. #include <cstdlib>
  9. #include <ctime>
  10. using namespace std;
  11.  
  12. int main() {
  13.   priority_queue<int> pqi;
  14.   srand(time(0)); // Seed random number generator
  15.   for(int i = 0; i < 100; i++)
  16.     pqi.push(rand() % 25);
  17.   while(!pqi.empty()) {
  18.     cout << pqi.top() << ' ';
  19.     pqi.pop();
  20.   }
  21. } ///:~
  22.